import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/utils/xindong_text_util.dart';
import 'package:xindong/widgets/common/xindong_app_bar.dart';
import 'package:xindong/widgets/common/xindong_app_bar_icon_button.dart';

class XinDongDialogAppBar extends StatelessWidget {
  final String title;

  // 左侧组件
  final Widget? leading;

  // 右侧按钮
  final String doneButtonName;
  final Function()? onTapDone;

  const XinDongDialogAppBar(this.title, {super.key, this.leading = const XinDongAppBarIconButton(), this.doneButtonName = "完成", this.onTapDone});

  @override
  Widget build(BuildContext context) {
    return MediaQuery.removePadding(
      context: context,
      removeTop: true,
      removeBottom: true,
      child: XinDongAppBar(
        title,
        leading: leading,
        actions: TextUtil.isEmpty(doneButtonName)
            ? null
            : [
                GestureDetector(
                  onTap: onTapDone,
                  behavior: HitTestBehavior.opaque,
                  child: Container(
                    width: 44,
                    alignment: Alignment.centerRight,
                    margin: const EdgeInsets.only(right: 16),
                    child: Text(
                      doneButtonName,
                      textAlign: TextAlign.center,
                      style: const TextStyle(color: DZColors.mainColor, fontSize: 16, fontWeight: FontWeight.w500),
                    ),
                  ),
                )
              ],
      ),
    );
  }
}
